package com.panda.web.mapper.wechat;

import com.panda.web.entity.wechat.WechatUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 公众号用户Mapper接口
 * 
 * @author cpanda
 * @date 2025-02-21
 */
@Mapper
public interface WechatUserMapper extends BaseMapper<WechatUser> {

    @Select("select * from wechat_user where openid=#{openId}")
    WechatUser findByOpenId(String openId);

    @Select("select * from wechat_user where official_openid=#{officialOpenid}")
    WechatUser findByOfficialOpenid(String officialOpenid);
    @Select("select * from wechat_user where unionid=#{unionId}")
    WechatUser findByUnionidOpenid(String unionId);
    @Select("select * from wechat_user where phone_number=#{phoneNumber}")
    WechatUser findByPhoneNumber(String phoneNumber);



    @Select("select openid from wechat_user where status = '0'")
    List<String> findByStatus();

//    @Select("select official_openid from wechat_user where status = '0' and official_openid IS NOT NULL AND official_openid != '' and follow_status ='1'")
//    List<String> findByOfficialOpenidStatus();

    @Select("select official_openid,openid from wechat_user where status = '0' and official_openid IS NOT NULL AND official_openid != '' and follow_status ='1' order by creation_time  DESC")
    List<WechatUser> findByOfficialOpenidStatusOb();
    @Select("select * from wechat_user ")
    List<WechatUser> selectByList();


    @Select("select u_id,openid,ceping_status,trial_status from wechat_user where openid=#{openId}")
    WechatUser findByOpenIdJOb(String openId);


}
